home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Collection of Tools & Utilities
/
Collection of Tools and Utilities.iso
/
comm
/
ca29_3.zip
/
PC-2-PC.SRC
< prev
next >
Wrap
Text File
|
1992-11-30
|
53KB
|
2,114 lines
S29 = "ATE0Q0V1X1S0=2 S7=30 S9=10^M" ; Modem init for autoconnect
S19 = "PC-2-PC ver 1.1 " ; 20 chars long
;
; ----- COM-AND Scripted PC-2-PC link
; Commenced: 09/20/88 R.McG
;
; Modified: 09/27/91
; 1. To correctly transfer filenames with special characters,
; such as "!" for both remote and local directories.
; .. 2. Also modified to use ZMODEM for all file transfers.
; .. 3. Also added CONNECT and DISCONNECT CLOG entries in order
; that CALOGS will be able to process direct connections too.
; -----------------------------------------------------------------------
; Goals:
; o Must autodetect connection
; o Must dial number on request
; o Must work correctly for modems reporting true CD and
; also for direct connects
;
; Functions:
; o Directory list - our current directory
; o Directory list - linked PC directory
; o Change subdirectory - our PC
; o Change subdirectory - linked PC
; o Transfers either way
; -----------------------------------------------------------------------
; Usages:
; FLAG(0) -> ON if link established
; FLAG(1) -> ON if caller or initiator of connect
; FLAG(2) -> Off if we are on 'our' side of the display
; FLAG(3) -> On if direct connect
;
; S29 -----> Modem initialization, including autoconnect command
; S19 -----> Legend line
; S18 -----> Load-time drive:subdirectory (for exit)
; S17 -----> Load-time download d:subdir (for exit)
;
; N99 -----> # screen lines
; N98 -----> Debugging flag (for one side, two side tests)
;
; N90 -----> Current cursor (1 to N99-5)
; N91 -----> # local files selected
; N92 -----> # remote files selected
;
; S16 -----> local files selected (13 chars/field)
; S15 -----> Remote files selected (13 chars/field)
;
; S12 -----> Used by Change sides for line read/write
; S11 -----> Used by various routines for saved file name
; S10 -----> Used by various routines for saved ON ESCAPE label
; -----------------------------------------------------------------------
;
; Initialization
;
LEGEND S19 ; Set initial legend
SUBDIR S18 ; Read current subdir
DLDIR S17 ; Read current download subdir
SET DLDIR " " ; Set download subdir to default
SET FLAG(0) OFF ; No current link
SET FLAG(1) ON ; Default - we called/initiated
SET FLAG(2) Off ; Default - on 'our side' of the display
SET FLAG(3) Off ; Default - dialed connect
SET CDISP ON ; Display control chars
SET RDISP OFF ; Don't display received chars
SET SOFTFLOW OFF ; Turn off our own flowctl
;SET HARDFLOW ON ; Turn on hdwe flowctl
SET ATIME 0 ; Set no alarm time
SET ALARM OFF ; Set no alarm sound
SET CHAT OFF ; Set chat off (just in case)
SET XSUI 10 ; Set transer screen update interval
ON ESCAPE GOSUB Exit ; Escape action
N90 = N91 = N92 = 0 ; Clear # files selected, cursor
S16 = ""
S15 = ""
;
; Make 8n1 for best KERMIT throughput
;
SET PARITY NONE
SET DATA 8
SET STOP 1
;
; Debugging flag
;
N98 = 0 ; Debugging if <> zero
;
; Draw the screen, and decide if we're linked
;
GOSUB InitScreen
GOSUB BuildLocDir ; Build our directory list
IF ZERO N98 ; Test for debugging
GOSUB LinkTest ; Not - make the link
ELSE
FOPENI "PC2PC.LOC" TEXT ; Open the file
ENDIF
;
; ----- Update the legend, and accept a command
;
Main:
LEGEND S19
LOCATE (N99-3),77 ; Set the cursor
SOUND 440,100 ; Indicate we're ready
SET TTHRU OFF
;
; Loop, waiting for a keypress or received commands
;
Main100:
IF HITKEY ; If a keypress pending
GOTO MAIN200 ; .. go handle it
ENDIF
IF RECEIVE ; If comm port chars pending
GOTO MAIN300 ; .. go handle it
ENDIF
IF ZERO N98 AND NOT CONNECTED
GOTO Exit
ENDIF
GOTO Main100 ; And loop
;
; We have a keypress pending
;
MAIN200:
KEYGET S1 ; Read a single key
SWITCH S1
CASE "C" ; Change directory
GOSUB ChangeOurDir
ENDCASE
CASE "E" ; Exit
GOTO Exit ; And exit
ENDCASE
CASE "H" ; Help
GOSUB Help
ENDCASE
CASE "S" ; Select
GOSUB Select
ENDCASE
CASE "T" ; Transfer
GOSUB Transfer
ENDCASE
CASE "W" ; Wildcard
GOSUB Wildcard ; Send using wildcards
ENDCASE
CASE "4D00" ; Cursor_Right
GOSUB Change_Sides
ENDCASE
CASE "4B00" ; Cursor left
GOSUB Change_Sides
ENDCASE
CASE "4900" ; PgUp
GOSUB Prev_Page
ENDCASE
CASE "5100" ; PgDn
GOSUB Next_Page
ENDCASE
CASE "4700" ; Home
GOSUB Home_Page
ENDCASE
CASE "4F00" ; End
GOSUB End_Page
ENDCASE
CASE "4800" ; Cursor Up
GOSUB Cursor_Up
ENDCASE
CASE "5000" ; Cursor down
GOSUB Cursor_Down
ENDCASE
CASE "7100" ; Alt-F10
SHELL
ENDCASE
DEFAULT
SOUND 100,100 ; Signal displeasure
ENDCASE
ENDSWITCH
GOTO Main ; And continue
;
; We have characters pending on the communications line
;
MAIN300:
RGET S1 1 ; Read a single character
SWITCH S1
CASE "R" ; Change directory
RGET S1 80 10 ; Read remainder
TRANSMIT "+!" ; Acknowlege
GOSUB Remote_Chdir
ENDCASE
CASE "E" ; Sender's local changed
GOTO Exit
ENDCASE
CASE "L" ; Sender's local changed
RGET S1 80 10 ; Read remainder
TRANSMIT "+!" ; Acknowlege
GOSUB Local_Chdir
ENDCASE
CASE "T" ; Sender wants to transfer
RGET S1 80 10 ; Read remainder - note no ACK
GOSUB Rcv_Transfer
ENDCASE
CASE "W" ; Sender's wants to xfer batch
RGET S1 80 10 ; Read remainder - note no ACK
GOSUB Rcv_Wildcard
ENDCASE
; CASE "^M" ; Carriage rtn
; ENDCASE ; Ignore it
CASE "?" ; Link request
TRANSMIT "PC-2-PC!"
SET FLAG(1) OFF ; Indicate we're receiving
GOSUB Exchange ; Exchange directories
ENDCASE ; Ignore it
DEFAULT ; Unrecognized
RFLUSH ; Clear line
GOTO Main100 ; And continue w/o beep
ENDCASE
ENDSWITCH
GOTO Main ; And continue
;
; ----- Exit procedure - ESC has been hit
; .. Restore screen, close files and delete temps
;
Exit:
IF FLAG (0) ; If linked
TRANSMIT "E!" ; Terminate remote too
SET FLAG(0) OFF
ENDIF
TSINCE (9) N9,N8,N7
S3 = "DISCONNECT: ("&N9&":"&N8&":"&N7&")"
CLOG S3
IF CONNECTED and NOT FLAG(3)
HANGUP ; Hangup if not direct
ENDIF
DO ; There may be multiple saves outstanding
RESTORE ; .. restore all
UNTIL FAILURE
FCLOSEI ; CLose files
FCLOSEO ; ..
DELETE "PC2PC.LOC" ; And delete them too
DELETE "PC2PC.REM" ; ..
CHDIR S18 ; Reset current subdir
; *** SET HARDFLOW OFF ; Disable
;
; ----- Terminate COM-AND and the script
;
SET CDRESPECT ON ; Skip 'connected' query on exit
BYE ; Terminate script AND COM-AND
;
; ----- Alternative to above... exit script
; .. exchange this paragraph and the above if you want it this way
; .. taking off the "***"s
;
*** RESET ; Reset default parameters (bye doesn't care)
*** EXIT ; And exit script
;
; ----- Subroutine: Clear the current cursor
; .. according to the current stting of FLAG(2)
;
Clear_Cursor:
IF NOT ZERO N90
GOSUB Read_Cursor
IF FLAG(2) ; IF true we're on remote
ATSAY N90,41 (default) S12
ELSE
ATSAY N90, 2 (default) S12
ENDIF
ENDIF
RETURN
;
; ----- Subroutine: Display the current cursor
; .. according to the current stting of FLAG(2)
;
Set_Cursor:
GOSUB Read_Cursor
IF NOT ZERO N90
IF FLAG(2) ; IF true we're on remote
IF NOT NULL S12
ATSAY N90,41 (contrast) S12
ELSE
N90 = N90-1
GOTO Set_Cursor
ENDIF
ELSE ; On own side
IF NOT NULL S12
ATSAY N90, 2 (contrast) S12
ELSE
N90 = N90-1
GOTO Se